package com.thn.netty.chat.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.ResourceBundle;

import org.apache.log4j.Logger;

public class RedisKeyProperties {

	private static final Logger logger = Logger
			.getLogger(RedisKeyProperties.class);
	private static final Properties p = new Properties();
	private static ResourceBundle resource;

	public static String domain_dept;
	public static String user_dept;
	public static String user_group;
	public static String dept_user;
	public static String dept_subdept;
	public static String group_user;
	public static String group_phone;
	public static String username_id;
	public static String phone_id;
	public static String email_id;
	public static String user_session;
	public static String session_user;
	public static String user_dialogs;
	public static String user_dialog_msg;
	public static String user_dialog_lastreceipt;


	public static String sync_db;
	public static String sync_login;
	public static String sync_msg_channel;
	

	public static String ims_broadcast;
	public static String sms_broadcast;
	

	static {
		InputStream in = null;
		try {
/*			in = RedisKeyProperties.class
					.getResourceAsStream("redis.key.properties");
			p.load(in);*/
			resource = ResourceBundle.getBundle("rediskey");
			domain_dept = getString("domain_dept");
			user_dept = getString("user_dept");
			user_group = getString("user_group");
			dept_user = getString("dept_user");
			dept_subdept = getString("dept_subdept");
			group_user = getString("group_user");
			group_phone = getString("group_phone");
			username_id = getString("username_id");
			phone_id = getString("phone_id");
			email_id = getString("email_id");
			user_session = getString("user_session");
			session_user = getString("session_user");
			user_dialogs = getString("user_dialogs");
			user_dialog_msg = getString("user_dialog_msg");
			user_dialog_lastreceipt = getString("user_dialog_lastreceipt");
			sync_db = getString("sync_db");
			sync_login = getString("sync_login");
			sync_msg_channel = getString("sync_msg_channel");			
			ims_broadcast = getString("ims_broadcast");
			sms_broadcast = getString("sms_broadcast");
		} catch (Exception e) {
			logger.error("读取redis.key.properties错误", e);
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public static String getString(String key) {
		try {
			return resource.getString(key);
		} catch (Exception e) {
			return null;
		}
	}

}
